const express = require('express') // express框架
// body-parser是非常常用的一个express中间件，作用是对http请求体进行解析
const bodyParser = require('body-parser') 
// const getInfo = require('./api/getInfo') // 上面说的后台接口文件


//配置后端接口文件
const getUserList = require('./api/getUserList') 
const getImg = require('./api/getImg')
const getRelateimg = require('./api/getRelateimg')
const subgoods = require('./api/subgoods')
const getsubgoods = require('./api/getUsersSubgoods')
const getAlluser = require('./api/getAllUserlist')
const getAllAdmin = require('./api/getAllAdminlist')
const getAllMessage = require('./api/getAllMessage')
const addNews = require('./api/addNews')
const getAllNews = require('./api/getAllNews')
const addGoodslist = require('./api/addGoodslist')
const addGoodsPublist = require('./api/addGoodsPublist')
const getAllGoodslist = require('./api/getAllGoodslist')
const getAllGoodspublist = require('./api/getAllGoodspublist')
const getUserMesslist = require('./api/getUserMesslist')
const deleteNewslist = require('./api/deleteNewslist')
const deleteMessagelist = require('./api/deleteMessagelist')
const deleteUserlist = require('./api/deleteUserlist')
const deleteGoodslist = require('./api/addGoodslist')
const deletePubgoodslist = require('./api/deletePubgoodslist')
const deleteSubgoodslist = require('./api/deleteSubgoodslist')
const updateNewslist = require('./api/updateNewslist')
const updateUserlist = require('./api/updateUserlist')
const updateUserPaylist = require('./api/updateUserPaylist')
const updateUserLoginlist = require('./api/updateUserLoginlist')
const addUserMessagelist = require('./api/addUserMessagelist')
const addUserlist = require('./api/addUserlist')
const getUserEarnlist = require('./api/getUserEarnlist')
const getUserMoneylist = require('./api/getUserMoneylist')
const updateUserMoneylist = require('./api/updateUserMoneylist')
const addUserEarnlist = require('./api/addUserEarnlist')
const addAuctionlist = require('./api/addAuctionlist')
const updateGoodsMaxPlist = require('./api/updateGoodsMaxPlist')
const getUserAuctionlist = require('./api/getUserAuctionlist')
const addOrderlist = require('./api/addOrderlist')
const getOrderlist = require('./api/getOrderlist')
const getUserOrderlist = require('./api/getUserOrderlist')
const getAllOrderlist = require('./api/getAllOrderlist')
const getAllAuctionlist = require('./api/getAllAuctionlist')
const getGoodslist = require('./api/getGoodslist')
const getCartlist = require('./api/getCartlist')
const addSendbacklist = require('./api/addSendbacklist')
const getSendbacklist = require('./api/getSendbacklist')
const updateGoodsPailist = require('./api/updateGoodsPailist')
const getUserIdlist = require('./api/getUserIdlist')
const getUserMoney = require('./api/getUserMoney')
const updateOrderslist = require('./api/updateOrderslist')
const updateGoodsIspaylist = require('./api/updateGoodsIspaylist')
const updateUserCredit = require('./api/updateUserCredit')
const getUserCredit = require('./api/getUserCredit')
const addUserSearchlist = require('./api/addUserSearchlist')
const getUserSearchlist = require('./api/getUserSearchlist')
const addMoneyChangelist = require('./api/addMoneyChangelist')
const getMoneyChangelist = require('./api/getMoneyChangelist')
const addUserCollectlist = require('./api/addUserCollectlist')
const getCollectGoodsIdlist = require('./api/getCollectGoodsIdlist')
const deleteCollectlist = require('./api/deleteCollectlist')
const getUsercollectlist = require('./api/getUsercollectlist')

const app = express()

// 静态文件托管
app.use(express.static('upload'))

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))

// 配置后端api路由
// 获取用户信息
app.use('/userlist', getUserList)
// 获取数据库图片路径
app.use('/getimg',getImg)
// 获取相关图片路径
app.use('/getRelateimg',getRelateimg)
// 添加用户提交竞拍商品信息
app.use('/addGoodssubmit', subgoods)
// 获取用户提交商品信息
app.use('/getGoodssubmit', getsubgoods)
// 获取所有用户信息
app.use('/getAllUser',getAlluser)
// 获取所用的管理员信息
app.use('/getAllAdmin',getAllAdmin)
// 获取所有用户留言
app.use('/getAllOrder',getAllMessage)
// 添加新闻资讯
app.use('/addNewsList',addNews)
// 获取所有的新闻资讯
app.use('/getAllNewsList',getAllNews)
//添加商品信息
app.use('/addGoods',addGoodslist)
// 添加竞拍商品信息
app.use('/addGoodsPub',addGoodsPublist)
// 获取所有的竞拍商品的信息
app.use('/getAllGoods',getAllGoodslist)
// 获取所有的管理员提交商品信息
app.use('/getAllGoodspub',getAllGoodspublist)
// 获取用户的留言信息
app.use('/getUserMessage',getUserMesslist)
// 根据id删除新闻
app.use('/deleteNews',deleteNewslist)
// 根据id删除留言
app.use('/deleteMessage',deleteMessagelist )
// 根据用户id删除用户信息
app.use('/deleteUser',deleteUserlist)
// 根据商品id删除商品信息
app.use('/deleteGoods',deleteGoodslist)
// 根据id删除发布的商品信息
app.use('/deletePubgoods',deletePubgoodslist)
//根据id删除用户提交商品信息
app.use('/deleteSubgoods',deleteSubgoodslist)
// 更新新闻信息
app.use('/updateNews',updateNewslist)
// 更新用户的部分信息
app.use('/updateUser',updateUserlist)
// 更新用户的支付密码
app.use('/upeateUserPay',updateUserPaylist)
// 更新用户密码
app.use('/updateUserLogin',updateUserLoginlist)
// 添加用户评论信息
app.use('/addUserMessage',addUserMessagelist)
// 注册用户
app.use('/addUser',addUserlist)
// 获取该用户是否交了保证金
app.use('/getUserEarn',getUserEarnlist)
// 获取用户余额
app.use('/getUserMoney',getUserMoneylist)
// 更新用户余额
app.use('/updateUserMoney',updateUserMoneylist)
// 添加用户是否提交押金
app.use('/addUserEarn',addUserEarnlist)
// 添加用户竞拍信息
app.use('/addAuction',addAuctionlist)
// 更新商品最高价
app.use('/updateGoodsMaxP',updateGoodsMaxPlist)
// 获取商品的竞拍信息
app.use('/getUserAuction',getUserAuctionlist)
// 添加订单
app.use('/addOrder',addOrderlist)
//通过商品Id获取商品订单
app.use('/getOrder',getOrderlist)
//通过用户Id获取订单
app.use('/getUserOrder',getUserOrderlist)
//获取所有订单
app.use('/getAllOrder',getAllOrderlist)
//获取所有竞拍信息
app.use('/getAllAuction',getAllAuctionlist)
//根据商品号获取商品
app.use('/getGoods',getGoodslist)
// 获取绘图信息
app.use('/getCart',getCartlist)
//添加退回原因
app.use('/addSendback',addSendbacklist)
//根据用户id获取消息
app.use('/getSendback',getSendbacklist)
//更新商品是否拍卖成功
app.use('/updateGoodsPai',updateGoodsPailist)
//通过商品id获取提交商品的用户id
app.use('/getUserId',getUserIdlist)
//通过用户id获取用户余额
app.use('/getMoney',getUserMoney)
//更新订单状态
app.use('/updateOrders',updateOrderslist)
//更新商品状态
app.use('/updateGoodsIspay',updateGoodsIspaylist)
//更新用户信誉度
app.use('/updateCredit',updateUserCredit)
//获取用户信誉度
app.use('/getCredit',getUserCredit)
//添加用户搜索关键词
app.use('/addUserSearch',addUserSearchlist)
//获取所有用户的搜索关键词
app.use('/getUserSearch',getUserSearchlist)
//添加资金流动
app.use('/addMoneyChange',addMoneyChangelist)
//获取资金流动信息
app.use('/getMoneyChange',getMoneyChangelist)
//收藏商品
app.use('/addUserCollect',addUserCollectlist)
//通过用户id查询所有的商品id
app.use('/getCollectGoodsId',getCollectGoodsIdlist)
// 通过用户id与商品id删除收藏商品
app.use('/deleteCollect',deleteCollectlist)
//根据用户id获取收藏商品
app.use('/getUsercollect',getUsercollectlist)

// 监听端口
app.listen(3000) // 监听server3000端口
console.log('success listen at port:3000')
